$(function() {
	$('.edas-line-iv-middle').on('click', function() {
		$('.toCenter:first').hide(1000, "swing");
		setTimeout(function() {
			$('.toCenter:last').show(1000, "swing");
			$('.bigBox').css({
				"animation": "boxShake 3s"
			});
		}, 1000);
		
		// 基于准备好的dom，初始化echarts实例
		var myChart = echarts.init(document.getElementById('test'));
		// 指定图表的配置项和数据
		var geoCoordMap = {
			'begin': [140, 60],
			'box1': [280, 200],
			'box2': [118.7073, 370.5513]
		};
		var BJData = [
			[{
				name: 'begin'
			}, {
				name: 'box1',
				value: 95
			}],
			[{
				name: 'begin'
			}, {
				name: 'box2',
				value: 90
			}]
		];
		var planePath = 'path://M1705.06,1318.313v-89.254l-319.9-221.799l0.073-208.063c0.521-84.662-26.629-121.796-63.961-121.491c-37.332-0.305-64.482,36.829-63.961,121.491l0.073,208.063l-319.9,221.799v89.254l330.343-157.288l12.238,241.308l-134.449,92.931l0.531,42.034l175.125-42.917l175.125,42.917l0.531-42.034l-134.449-92.931l12.238-241.308L1705.06,1318.313z';
		var convertData = function(data) {
			var res = [];
			for (var i = 0; i < data.length; i++) {
				var dataItem = data[i];
				var fromCoord = geoCoordMap[dataItem[0].name];
				var toCoord = geoCoordMap[dataItem[1].name];
				if (fromCoord && toCoord) {
					res.push([{
						coord: fromCoord
					}, {
						coord: toCoord
					}]);
				}
			}
			return res;
		};
		var color = 'whitesmoke';
		var img = 'pin';
		var series = [];
		[
			['begin', BJData]
		].forEach(function(item, i) {
			series.push({
				type: 'lines',
				zlevel: 3,
				effect: {
					show: true,
					period: 6,
					trailLength: 0.7,
					color: color,
					symbolSize: 3
				},
				lineStyle: {
					normal: {
						color: color,
						width: 0,
						curveness: 0.2
					}
				},
				data: convertData(item[1])
			}, {
				name: item[0] + ' Top10',
				type: 'lines',
				zlevel: 1,
				effect: {
					show: true,
					period: 6,
					trailLength: 0,
					symbol: img,
					symbolSize: 3
				},
				lineStyle: {
					normal: {
						color: color,
						width: 0,
						opacity: 0.4,
						curveness: 0.2
					}
				},
				data: convertData(item[1])
			}, {
				name: item[0] + ' Top10',
				type: 'effectScatter',
				coordinateSystem: 'geo',
				zlevel: 2,
				rippleEffect: {
					brushType: 'stroke'
				},
				label: {
					normal: {
						show: false,
						position: 'right',
						formatter: '{b}'
					}
				},
				symbolSize: function(val) {
					return val[2] / 8;
				},
				itemStyle: {
					normal: {
						show: false,
						opacity: 0.1,
						color: color
					}
				},
				data: item[1].map(function(dataItem) {
					return {
						name: dataItem[1].name,
						value: geoCoordMap[dataItem[1].name].concat([dataItem[1].value])
					};
				})
			});
		});
		option = {
			geo: {
				label: {
					emphasis: {
						show: false
					}
				},
				roam: true
			},
			series: series
		};
		// 使用刚指定的配置项和数据显示图表。
		myChart.setOption(option);
		
		
	});
});